import Axios from 'axios'

let baseURL = ""
// 判断是开发环境还是生成环境
// console.log(process.env);
if (process.env.NODE_ENV == "development") {//开发环境
    // baseURL="http://172.21.105.114:3000"
    baseURL = "http://localhost:3000"
} else if (process.env.NODE_ENV == "production") {//生产环境
    baseURL = "http://localhost:3000"
}

const instance = Axios.create({
    baseURL,
    timeout: 1000 * 2
})

//导出
export default function http(url, method, params = {}, data = {}) {
    return instance({
        url,
        method,
        params,
        data
    }).then(res => {
        return res.data
    }).catch(err => {
        return Promise.reject(err)
    })
}